home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part1 / 5709 < prev    next >
Encoding:
Text File  |  1996-08-05  |  5.1 KB  |  202 lines

  1. Path: cleveland.Freenet.Edu!cj841
  2. From: cj841@cleveland.Freenet.Edu (Chris Steiner)
  3. Newsgroups: comp.lang.c++
  4. Subject: Need help with MSVC++
  5. Date: 6 Feb 1996 14:19:31 GMT
  6. Organization: Case Western Reserve University, Cleveland OH (USA)
  7. Message-ID: <4f7o1j$gr7@madeline.INS.CWRU.Edu>
  8. NNTP-Posting-Host: nextsun.ins.cwru.edu
  9.  
  10.  
  11. Please, I really need help on this guys.  I'm new at this and desperately 
  12. trying to figure out what to do.  I'm using the AppWizard, which seems to have 
  13. firmly put me in over my head, yet with a little hope.  
  14.   
  15. Perhaps I did not explain my problem clearly enough in my first post, so I'll 
  16. try again.  
  17.   
  18. I need, in Visual C++ 1.52, to create a modal dialog box that accesses a 
  19. database.  This dialog box must connect to the database as it is opened.  I 
  20. may need to prompt the user for the location of the database, so I do not want 
  21. the connection formed until the user selects that particular menu option.  
  22.   
  23. This should be relatively simple.  I thought it could be done with code such 
  24. as this:  
  25.   
  26. (in tali.h)
  27.  
  28. /////////////////////////////////////////////////////////////////////////////
  29. // CSingleDialog dialog
  30.  
  31. class CSingleDialog : public CDialog
  32. {
  33. // Construction
  34. public:
  35.     CSingleDialog(CWnd* pParent = NULL);    // standard constructor
  36.  
  37. // Dialog Data
  38.     //{{AFX_DATA(CSingleDialog)
  39.     enum { IDD = D_SINGLE_EDIT };
  40.     CSingRecord*    m_pSet;
  41.     //}}AFX_DATA
  42.     char added[64];
  43.     char cur_title[48];
  44.     char deleted[64]; 
  45.     struct INFO *first;
  46.  
  47. // Implementation
  48. protected:
  49.     CComboBox& List()
  50.         {return *(CComboBox*)GetDlgItem(COM_SINGLE); }
  51.     CButton& Undo()
  52.         {return *(CButton*)GetDlgItem(BUT_STREET_UNDO); }
  53.     virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
  54.  
  55.     // Generated message map functions
  56.     //{{AFX_MSG(CSingleDialog)  
  57.     afx_msg void OnSingleAdd();
  58.     afx_msg void OnSingleDel();
  59.     afx_msg void OnSingleUndo();
  60.     virtual void Redraw();
  61.     virtual void OnOK();          
  62.     virtual void OnCancel();
  63.     virtual int DeleteItem(char *);
  64.     virtual int AddItem(char *);
  65.     afx_msg void OnEditchangeSingle();
  66.     virtual BOOL OnInitDialog();
  67.     //}}AFX_MSG
  68.     DECLARE_MESSAGE_MAP()
  69. };
  70.  
  71. class CRecviewSet : public CRecordset
  72. {
  73. DECLARE_DYNAMIC(CRecviewSet)
  74.  
  75. public:
  76.     CRecviewSet(CDatabase* pDatabase = NULL);
  77.  
  78. // Field/Param Data
  79.     //{{AFX_FIELD(CRecviewSet, CRecordset)
  80.     //}}AFX_FIELD
  81.  
  82. // Implementation
  83. protected:                
  84. };
  85.  
  86.  
  87.  
  88. (int talidoc.h)
  89.  
  90. class CTaliDoc : public CDocument
  91. {
  92. protected: // create from serialization only
  93.     CTaliDoc();
  94.     DECLARE_DYNCREATE(CTaliDoc)
  95.  
  96. // Attributes
  97. public:
  98.     CSectionSet m_sectionSet;
  99. // Operations
  100. public:
  101.  
  102. // Implementation
  103. public:
  104.     virtual ~CTaliDoc();
  105.     virtual void Serialize(CArchive& ar);   // overridden for document i/o
  106. #ifdef _DEBUG
  107.     virtual void AssertValid() const;
  108.     virtual void Dump(CDumpContext& dc) const;
  109. #endif
  110.  
  111. protected:
  112.     virtual BOOL OnNewDocument();
  113.  
  114. // Generated message map functions
  115. protected:
  116.     //{{AFX_MSG(CTaliDoc)
  117.         // NOTE - the ClassWizard will add and remove member functions 
  118. here.
  119.         //    DO NOT EDIT what you see in these blocks of generated code!
  120.     //}}AFX_MSG
  121.     DECLARE_MESSAGE_MAP()
  122. };
  123.  
  124.  
  125.  
  126. (in tali.cpp)  
  127.   
  128. BOOL CSingleDialog::OnInitDialog()
  129. {
  130.     char buffer[512];
  131.     long i;
  132.     struct INFO *temp;
  133.  
  134.     first = NULL;
  135.     CTaliDoc * pDoc=(CTaliDoc *) (GetParentFrame()->GetActiveDocument());
  136.     switch (SingleType) {
  137.         case E_STREET: 
  138.             strcpy(cur_title,"Edit Street Table");
  139.             //SetTitle(cur_title);
  140.             m_pSet= &(pDoc->m_sectionSet);
  141.             m_pSet->Open();
  142.             List().LimitText(40);
  143.             for(i=0;i<2000;i++) {
  144.                 sprintf(buffer,"%d",i);
  145.                 AddItem(buffer);      
  146.             }
  147.             for(temp=first;temp;temp=temp->next) {
  148.                 temp->state='N';
  149.             }
  150.             break;
  151.         default:
  152.             break;    
  153.     } 
  154.     dbData.SetLoginTimeout(60);
  155.     dbData.SetQueryTimeout(60);
  156.     Undo().EnableWindow(FALSE);
  157.     added[0]='\0';
  158.     deleted[0]='\0';
  159.     
  160.     CDialog::OnInitDialog();
  161.                 
  162.     return TRUE;  // return TRUE  unless you set the focus to a control
  163. }
  164.  
  165.  
  166.  
  167. However, this gives me the following errors:  
  168.   
  169. Initializing...
  170. Compiling...
  171. c:\msvc\bin\tali\tali.cpp
  172. c:\msvc\bin\tali\talidoc.h(13) : error C2501: 'CSectionSet' : missing decl-
  173. specifiers
  174. c:\msvc\bin\tali\talidoc.h(13) : error C2146: syntax error : missing ';' 
  175. before identifier 'm_sectionSet'
  176. c:\msvc\bin\tali\talidoc.h(13) : error C2501: 'm_sectionSet' : missing decl-
  177. specifiers
  178. c:\msvc\bin\tali\tali.cpp(1107) : error C2039: 'm_sectionSet' : is not a 
  179. member of 'CTaliDoc'
  180. c:\msvc\bin\tali\talidoc.cpp
  181. c:\msvc\bin\tali\talidoc.h(13) : error C2501: 'CSectionSet' : missing decl-
  182. specifiers
  183. c:\msvc\bin\tali\talidoc.h(13) : error C2146: syntax error : missing ';' 
  184. before identifier 'm_sectionSet'
  185. c:\msvc\bin\tali\talidoc.h(13) : error C2501: 'm_sectionSet' : missing decl-
  186. specifiers
  187. c:\msvc\bin\tali\taliview.cpp
  188. c:\msvc\bin\tali\talidoc.h(13) : error C2501: 'CSectionSet' : missing decl-
  189. specifiers
  190. c:\msvc\bin\tali\talidoc.h(13) : error C2146: syntax error : missing ';' 
  191. before identifier 'm_sectionSet'
  192. c:\msvc\bin\tali\talidoc.h(13) : error C2501: 'm_sectionSet' : missing decl-
  193. specifiers
  194.  CL returned error code 2.
  195. TALI.EXE - 10 error(s), 0 warning(s)
  196.  
  197. Am I even going in the right direction?
  198.  
  199. If anyone has sample code that I can look at or can explain what I can do to 
  200. fix my current delema, I would greatly appreciate it.  
  201.  
  202.